package com.springcloud.demo.dynamicTable.dynamic.service.serviceImpl;

import com.springcloud.demo.dynamicTable.autocode.utils.StringUtils;
import com.springcloud.demo.dynamicTable.dynamic.dao.CodeDao;
import com.springcloud.demo.dynamicTable.dynamic.entity.CodeDO;
import com.springcloud.demo.dynamicTable.dynamic.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;



@Service
public class CodeServiceImpl implements CodeService {
	@Autowired
	private CodeDao codeDao;
	
	@Override
	public CodeDO get(String id){
		return codeDao.get(id);
	}
	
	@Override
	public List<CodeDO> list(Map<String, Object> map){
		return codeDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return codeDao.count(map);
	}
	
	@Override
	public int save(CodeDO code){
	    if (StringUtils.isEmpty(code.getId())) {
            code.setId(StringUtils.getUUID());
		}

		return codeDao.save(code);
	}
	
	@Override
	public int update(CodeDO code){
		return codeDao.update(code);
	}
	
	@Override
	public int remove(String id){
		return codeDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return codeDao.batchRemove(ids);
	}
	
}
